// 引入相关组件
import Login from "@/pages/Login";
import Register from "@/pages/Register";
import Userspace from "@/pages/Userspace";


export default [
    {
        path: "/home",
        component: () => import("@/pages/Home"),
        meta: {
            // 底部组件是否显示的元数据
            footerShow: true,
            // 显示第几套头部的元数据
            Header: 1
        }
    },
    {
        path: "/search/:keyword?",
        name: "search",
        component: () => import("@/pages/Search"),
        meta: {
            // 底部组件是否显示的元数据
            footerShow: true,
            Header: 2
        }
    },
    {
        path: "/detail/:goodId",
        name: "detail",
        component: () => import("@/pages/Detail"),
        meta: {
            footerShow: true,
            Header: 2
        }
    },
    {
        path: "/addshopcartsuccess",
        component: () => import("@/pages/AddShopcartSuccess"),
        meta: {
            footerShow: true,
            Header: 2
        }
    },
    {
        path: "/shopcart",
        name: "shopcart",
        component: () => import("@/pages/Shopcart"),
        meta: {
            footerShow: true,
            Header: 4,
            title: "我的购物车"
        }
    },
    {
        path: "/trade",
        component: () => import("@/pages/Trade"),
        meta: {
            footerShow: true,
            Header: 4,
            title: "确认订单"
        },
        beforeEnter: (to, from, next) => {
            // 只有从购物车才能进入订单页面
            if (from.path == "/shopcart" || from.path == "/") {
                next();
            } else {
                next(false);
            }
        }
    },
    {
        path: "/pay",
        component: () => import("@/pages/Pay"),
        meta: {
            footerShow: true,
            Header: 4,
            title: "支付订单"
        },
        beforeEnter: (to, from, next) => {
            if (from.path == "/trade" || from.path == "/") {
                next();
            } else {
                next(false);
            }
        }
    },
    {
        path: "/paysuccess",
        component: () => import("@/pages/Paysuccess"),
        meta: {
            footerShow: true,
            Header: 4,
            title: "支付成功"
        }
    },
    {
        path: "/orderdetail",
        name: "orderdetail",
        component: () => import("@/pages/OrderDetail"),
        meta: {
            footerShow: true,
            Header: 4,
            title: "订单详情"
        }
    },
    {
        path: "/userspace",
        name: "userspace",
        component: Userspace,
        meta: {
            footerShow: false,
            Header: 3
        },
        redirect: "/userspace/personal",
        children: [
            {
                path: "personal",
                component: () => import("@/pages/Userspace/Main/Personal"),
                meta: {
                    footerShow: true,
                    Header: 3
                },
            },
            {
                path: "mypublic",
                component: () => import("@/pages/Userspace/Main/Mypublic"),
                meta: {
                    footerShow: true,
                    Header: 3
                },
            },
            {
                path: "mytrade",
                component: () => import("@/pages/Userspace/Main/MyTrade"),
                meta: {
                    footerShow: true,
                    Header: 3
                },
            },
            {
                path: "/userspace/settings",
                component: () => import("@/pages/Userspace/Main/Settings"),
                meta: {
                    footerShow: true,
                    Header: 3
                },
                redirect: "/userspace/settings/infoSelf",
                children: [
                    {
                        path: "infoSelf",
                        component: () => import("@/pages/Userspace/Main/Settings/InfoSelf"),
                        meta: {
                            footerShow: true,
                            Header: 3
                        },
                    },
                    {
                        path: "editPwd",
                        component: () => import("@/pages/Userspace/Main/Settings/EditPwd"),
                        meta: {
                            footerShow: true,
                            Header: 3
                        },
                    },
                    {
                        path: "editEmail",
                        component: () => import("@/pages/Userspace/Main/Settings/EditEmail"),
                        meta: {
                            footerShow: true,
                            Header: 3
                        },
                    },
                ]
            }
        ]
    },
    {
        path: "/login",
        component: Login,
        meta: {
            // 底部组件是否显示的元数据
            footerShow: false,
            Header: 0
        }
    },
    {
        path: "/register",
        component: Register,
        meta: {
            // 底部组件是否显示的元数据
            footerShow: false,
            Header: 0
        }
    },
    // 重定向
    {
        path: "*",
        redirect: "/home"
    }
]